<template>
  <div class="login-title">忘记密码</div>

  <el-form :model="formData" ref="loginFormRef" label-position="top" class="login-form">
    <el-form-item label="用户名">
      <el-input v-model="formData.username" placeholder="请输入用户名" />
    </el-form-item>

    <el-form-item label="密码">
      <el-input
        v-model="formData.password"
        type="password"
        placeholder="请输入密码"
        show-password
      />
    </el-form-item>

    <div class="flex-row register-box">
      <el-checkbox v-model="isRemember" label="记住密码"></el-checkbox>
      <el-link type="primary" underline="never" @click="toRegister">注册账号</el-link>
    </div>
    <el-button type="primary" class="login-btn" @click="handleLogin">登录</el-button>
  </el-form>

  <div class="login-links flex-row flex-center w100">
    <div @click="toForgot">忘记密码？</div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';

const formData = ref({
  username: '',
  password: '',
});
const isRemember = ref(false);

const loginFormRef = ref();

const handleLogin = () => {
  if (!formData.value.username || !formData.value.password) {
    ElMessage.warning('请输入用户名和密码');
    return;
  }
  ElMessage.success(`登录成功，欢迎 ${formData.value.username}！`);
};

const toRegister = () => {
  ElMessage('跳转注册页面');
};

const toForgot = () => {
  ElMessage('跳转找回密码页面');
};
</script>

<style scoped lang="less">
.login-wrapper {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 100% 100%, #f5f5f5 0%, #f5f5f5 100%);
  z-index: 0;
}

.login-content {
  position: relative;
  z-index: 1;
  width: 450px;
  max-width: 90%;
  animation: fade-in 0.8s ease-out;
  border: 1px solid #ececec;
  border-radius: 10px;
}

.login-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 40px;
}

.login-title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  text-align: center;
  margin-bottom: 30px;
}

.login-form {
  .register-box {
    justify-content: space-between;
  }
}

.login-btn {
  width: 100%;
  margin-top: 10px;
  background-color: #7c3aed;
  border-color: #7c3aed;
}

.login-links {
  display: flex;
  margin-top: 20px;
  font-size: 14px;
}

@keyframes fade-in {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0px);
    opacity: 1;
  }
}
</style>
